import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'
import GoodsImg from "@/components/goods/goods-img"
import './index.scss'
import { toGoodsPage } from '@/utils/page_router'
import {NeedScore, SalePrice} from "@/components/index";

interface IProps {
  list: any
}

/**
 * 自定义列表展示5
 */
export default class Index extends Component<IProps, {}> {
  props: any

  static options = {
    addGlobalClass: true
  }

  render() {
    const { list=[] }:any = this.props
    return (<View className='custom-five d-f f-d-c'>
      {list.map(goods => {
        return (<View key={goods.id} className='goods-item' onClick={() => toGoodsPage(goods)}>
          <View className='goods-img'>
            <GoodsImg src={goods.coverImg} info={goods} lazyLoad/>
            {goods.salesNumber && <View className='sold-num'>已兑换{goods.salesNumber}件</View>}
          </View>
          <View className='goods-foot'>
            <View className='goods-name'>
              <View className='name-text t-o-e-2'>{goods.name}</View>
            </View>
            <View className='d-f a-i-f-e j-c-b'>
              <View className='goods-price d-f a-i-b'>
                <NeedScore goods={goods} priceSize={44} className='m-r-10'/>
                <SalePrice goods={goods} priceSize={32}/>
                {/*<View className='sale-price bnn-number'>￥{goods.salePrice}</View>*/}
                {/*{goods.originPrice > goods.salePrice && <View className='origin-price bnn-number'>￥{goods.originPrice}</View>}*/}
              </View>
              <View className='goods-btn'>立即购买</View>
            </View>
          </View>
        </View>)
      })}
    </View>)
  }
}
